package qq2564874169.tuaotuao.fx.io;

import qq2564874169.tuaotuao.fx.utils.ExUtil;

import java.io.*;

public class StringWriter extends BufferedWriter {
    public StringWriter(Writer out) {
        super(out);
    }

    public StringWriter(OutputStream os) {
        this(new OutputStreamWriter(os));
    }

    public StringWriter(File file) throws FileNotFoundException {
        this(new FileOutputStream(file));
    }

    public StringWriter(String filename) throws FileNotFoundException {
        this(new File(filename));
    }

    public void writeLine(String line) {
        try {
            write(line);
            newLine();
        } catch (IOException e) {
            throw ExUtil.toRuntime(e);
        }
    }

    public void appendLine(String line) {
        try {
            append(line);
            newLine();
        } catch (IOException e) {
            throw ExUtil.toRuntime(e);
        }
    }

    @Override
    public void close() throws IOException {
        super.close();
    }
}
